package com.example.wjy.adapter;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

/**
 * author: WangJunYan
 * package: com.example.wjy.adapter
 * date: 2020/6/4
 * time: 15:53
 * 在MyTeamActivity中的ViewPager2的适配器，管理两个碎片，分别是
 * MyCreateTeamFragment,MyJoinTeamFragment
 */
public class MyTeamAdapter extends FragmentStateAdapter {

    /**
     * The list of fragments of ViewPager2 in MyTeamActivity.
     */
    public List<Fragment> fragments;

    public MyTeamAdapter(@NonNull FragmentActivity fragmentActivity, List<Fragment> fragments) {
        super(fragmentActivity);
        this.fragments = fragments;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return fragments.get(position);
    }

    @Override
    public int getItemCount() {
        return fragments.size();
    }
}
